package com.dxf.sysadmin.controller;

import com.dxf.common.utils.ResultJson;
import com.dxf.sysadmin.entity.Course;
import com.dxf.sysadmin.entity.Dept;
import com.dxf.sysadmin.service.DeptService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/dept")
@Api(tags  = "DeptController|部门控制器")
public class DeptController {
    @Autowired
    private DeptService deptService;

    /**
     * @Description: 部门列表treetable
     */
    @GetMapping("deptPage")
    @ApiOperation("部门列表treetable")
    public ResultJson deptPage(){
        return deptService.deptPage();
    }

    /**
     * @Description: 更具id列表删除部门
     */
    @DeleteMapping("delete/{id}")
    @ApiOperation(value = "更具id列表删除部门")
    public ResultJson deleteDept(@PathVariable Integer id){
        return deptService.deleteDept(id);
    }

    /**
     * @Description: 新增或者更新部门
     */
    @PostMapping("saveOrUpdate")
    @ApiOperation(value="新增或者更新部门")
    public ResultJson saveOrUpdateDept( @RequestBody Dept dept){
        return deptService.saveOrUpdateDept(dept);
    }

    /**
     * @Description: 部门添加时父级选择的SelectTree数据
     */
    @GetMapping("selectTree")
    @ApiOperation("部门添加时父级选择的SelectTree数据")
    public ResultJson selectTree(){
        return deptService.selectTree();
    }
}
